package com.struc.td;

/*
 * This is our sound class and it initiates our background music
 * and our other sound effects. It also implements our mute method
 */

import java.util.HashMap;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
public class Sounds{

	static int SOUND_SHOOT = 1;
	static int MUSIC_MUSIC = 1; 
	static int SOUND_DEATH = 2;
	private static boolean muted;
	static HashMap<Integer,Music> musicmap;
	static HashMap<Integer,Sound> soundmap;
	private static Music currentMusic;

	public Sounds(){
		muted = false;
		soundmap = new HashMap<Integer,Sound>();
		musicmap = new HashMap<Integer,Music>();	
		soundmap.put(1, Gdx.audio.newSound(Gdx.files.internal("data/skott.mp3")));
		musicmap.put(1, Gdx.audio.newMusic(Gdx.files.internal("data/chap2.mp3")));


	}
	public static void playMusic(int music){
		if(!muted){
			currentMusic= musicmap.get(music);		
			currentMusic.setLooping(true);
			currentMusic.setVolume(0.5f);
			currentMusic.play();
		}
	}
	public static void playSound (int sound){		
		if(!muted){
			soundmap.get(sound).play();	
		}		
	}
	
	public static boolean getMuted(){
		return muted;
	}
	
	public static void mute(){
		if(currentMusic != null){
			if(currentMusic.isPlaying()){
				currentMusic.pause();
			}
			else{
				currentMusic.play();
			}
		}
		if(muted)
			muted=false;
		else
			muted =true;
	}
}

